﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration.Install;
using System.ComponentModel;


namespace Windows_Web
{
    [RunInstaller(true)]//注意这里的属性Attribute设置
    class Install : Installer
    {
        private System.ComponentModel.IContainer components = null;
        private System.ServiceProcess.ServiceProcessInstaller spInstaller;
        private System.ServiceProcess.ServiceInstaller sInstaller;
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();

            // 创建ServiceProcessInstaller对象和ServiceInstaller对象
            this.spInstaller = new System.ServiceProcess.ServiceProcessInstaller();
            this.sInstaller = new System.ServiceProcess.ServiceInstaller();

            // 设定ServiceProcessInstaller对象的帐号、用户名和密码等信息
            this.spInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
            this.spInstaller.Username = null;
            this.spInstaller.Password = null;

            // 设定服务名称
            this.sInstaller.ServiceName = "Windows Web";
            sInstaller.DisplayName = "后台Windows服务";
            sInstaller.Description = "一个后台Windows运行的服务";

            // 设定服务的启动方式
            this.sInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
            this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.spInstaller, this.sInstaller });

        }
    }
}
